﻿using DalatCooking.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DalatCooking.Core.Helper;

public partial class UserControls_Widget : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        LoadModule_Right();

    }
    void LoadModule_Right()
    {
        List<Module> list = ModuleManager.FindAll().FindAll(c => c.Type == "WIDGET" && c.Position == "RIGHT");
        
        foreach (var item in list)
        {
            switch (item.Name)
            {
                case "WIDGET_WEATHER":

                    Widgets_Weather ucWeather = LoadControl(@"" + item.DataSource + "") as Widgets_Weather;
                    ucWeather.ModuleID = item.ModuleId;
                    ucWeather.Name = item.Name;
                    ucWeather.Title = item.Title;
                    ucWeather.Params = item.Params;
                    plhWidget.Controls.Add(ucWeather);
                    break;


                case "WIDGET_POLL":
                    Widgets_Poll ucPoll = LoadControl(@"" + item.DataSource + "") as Widgets_Poll;
                    ucPoll.ModuleID = item.ModuleId;
                    ucPoll.Name = item.Name;
                    ucPoll.Title = item.Title;
                    ucPoll.Params = item.Params;
                    plhWidget.Controls.Add(ucPoll);
                    break;


                case "WIDGET_HTML":
                    Widgets_Html ucHtml = LoadControl(@"" + item.DataSource + "") as Widgets_Html;
                    ucHtml.ModuleID = item.ModuleId;
                    ucHtml.Name = item.Name;
                    ucHtml.Title = item.Title;
                    plhWidget.Controls.Add(ucHtml);
                    break;
             
                case "WIDGET_SHOPPINGCART":
                    Widgets_Cart ucCart = LoadControl(@"" + item.DataSource + "") as Widgets_Cart;
                    ucCart.ModuleID = item.ModuleId;
                    ucCart.Name = item.Name;
                    ucCart.Title = item.Title;
                    ucCart.Params = item.Params;
                    plhWidget.Controls.Add(ucCart);
                    break;

                case "WIDGET_LOGIN":
                    Widgets_Login ucLogin = LoadControl(@"" + item.DataSource + "") as Widgets_Login;
                    ucLogin.ModuleID = item.ModuleId;
                    ucLogin.Name = item.Name;
                    ucLogin.Title = item.Title;
                    ucLogin.Params = item.Params;
                    plhWidget.Controls.Add(ucLogin);
                    break;
                case "WIDGET_SEARCH":
                    Widgets_Search ucSearch = LoadControl(@"" + item.DataSource + "") as Widgets_Search;
                    ucSearch.ModuleID = item.ModuleId;
                    ucSearch.Name = item.Name;
                    ucSearch.Title = item.Title;
                    ucSearch.Params = item.Params;
                    plhWidget.Controls.Add(ucSearch);
                    break;
                default:
                    break;
            }
        }
    }
}